﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ScopeTextBoxDemo
{
    public partial class SelectFieldDialog : Form
    {
        public SelectFieldDialog(Dictionary<string, bool> fields)
        {
            _fields = fields;
            InitializeComponent();
        }

        private Dictionary<string, bool> _fields;
        public Dictionary<string, bool> Fields
        {
            get { return this._fields; }
            set { this._fields = value; }
        }

        public string SelectedField
        {
            get { return (string)comboBoxField.SelectedItem; }
        }

        protected override void OnLoad(EventArgs e)
        {
            foreach (string field in Fields.Keys)
            {
                if (!Fields[field])
                {
                    comboBoxField.Items.Add(field);
                }
            }

            if (comboBoxField.Items.Count > 0)
                comboBoxField.SelectedIndex = 0;

            base.OnLoad(e);
        }

        private void btOk_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            Close();
        }

        private void btCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            Close();
        }
    }
}
